<template>
  <div>
    <div class="title">
      <van-icon name="arrow-left" @click="$router.back()" /><span
        >我的收藏</span
      >
    </div>
    <div class="content">
      <HouseListItem :HouseInfoList="favoriteList" />
    </div>
  </div>
</template>

<script>
import { favoriteAPI } from '@/api'
import HouseListItem from '@/components/HouseListItem'
export default {
  name: 'Favorite',
  data () {
    return {
      favoriteList: []
    }
  },
  components: {
    HouseListItem
  },
  created () {
    this.getFavoriteInfo()
  },
  methods: {
    async getFavoriteInfo () {
      try {
        const res = await favoriteAPI()
        this.favoriteList = res.data.body
        return Promise.resolve(res)
      } catch (error) {
        return Promise.reject(error)
      }
    }
  }
}
</script>

<style lang="less" scoped>
.title {
  position: fixed;
  z-index: 999;
  top: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background-color: #43b978;
  text-align: center;
  line-height: 40px;
  color: #fff;
  font-size: 18px;
  .van-icon-arrow-left {
    left: 15px;
    top: 10px;
    position: absolute;
    color: #fff;
    font-size: 16px;
  }
}
.content {
  margin-top: 45px;
}
</style>
